#include<iostream>
using namespace std;
typedef long long LL;
const LL mod = 1e9 + 7;
LL n;
int main()
{
	int t;	
	cin >> t;
	while (t--) {
		cin >> n;
		LL ans = (__int128)n * (n + 1) * (2 * n + 1) / 3 % mod;
		//ans += n * (n + 1) / 2;
		ans -= n * (n + 1) / 2;
		ans = (ans % mod + mod) % mod;
		ans = ans * 2022 % mod;
		cout << ans << endl;
	}
	return 0;
}	